﻿
using System;
using System.Collections.Generic;
namespace Jayden.Dll.Web.Styles
{
	public class CssSelector
	{
		private string m_Selector;
		private CssSelectorDescription[] m_Descriptions;
		private int m_Score = 0;

		public CssSelector(string selector)
		{
			m_Selector = selector;

			List<CssSelectorDescription> descriptions = CssSelectorDescription.Parse(selector);
			foreach (CssSelectorDescription d in descriptions)
				m_Score += d.Points;
			m_Descriptions = descriptions.ToArray();
		}

		public string Selector { get { return m_Selector; } }
		public int Score { get { return m_Score; } }

		public int CheckValidity()
		{
			int version = 0;
			foreach (CssSelectorDescription d in m_Descriptions)
				version = Math.Max(d.CssVersion, version);
			return version;
		}


		public override string ToString() { return m_Selector; }
	}
}
